'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, config: {urls} } = app;

  // 用户模块
  router.post(urls.user.register, controller.users.user.register)
  router.post(urls.user.login, controller.users.user.login)
  router.get(urls.user.getUserInfo, app.jwt, controller.users.user.getUserInfo)
  router.post(urls.user.userlist, controller.users.user.getUserList)
  router.post(urls.user.editUser, app.jwt, controller.users.user.editUser)
  router.delete(urls.user.deleteUser, controller.users.user.deleteUser)

  // 图书管理
  router.post(urls.book.storage, app.jwt, controller.books.book.storage)
  router.post(urls.book.reStorage, app.jwt, controller.books.book.reStorage)
  router.post(urls.book.list, controller.books.book.list)
  router.post(urls.book.listDel, controller.books.book.listDel)
  router.delete(urls.book.delete, controller.books.book.delete)
  router.delete(urls.book.deleteRel, controller.books.book.deleteRel)
  router.post(urls.book.update, controller.books.book.update)
  router.post(urls.book.onShelf, controller.books.book.shlef)

  // 图书分类管理
  router.post(urls.cate.create, app.jwt, controller.books.cate.create)
  router.delete(urls.cate.delete, controller.books.cate.delete)
  router.post(urls.cate.update, app.jwt, controller.books.cate.update)
  router.post(urls.cate.list, controller.books.cate.list)
  router.post(urls.cate.listselect, controller.books.cate.listselect)

  // 上传模块
  router.post(urls.upload.avatar, app.jwt, controller.uploads.upload)
};
